\hypertarget{classpg_input_event_manager}{\section{pg\-Input\-Event\-Manager Class Reference}
\label{classpg_input_event_manager}\index{pg\-Input\-Event\-Manager@{pg\-Input\-Event\-Manager}}
}


Pale\-Gem's keyboard event manager.  




{\ttfamily \#include $<$pg\-Input\-Event\-Manager.\-h$>$}

Inheritance diagram for pg\-Input\-Event\-Manager\-:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{classpg_input_event_manager}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{classpg_input_event_manager_a751b6861a24c5adc0bbf5a57a979a2fe}{pg\-Input\-Event\-Manager} ()
\item 
\hyperlink{classpg_input_event_manager_a1d1b1aaba16afa0c0c9d311f9b258c4e}{$\sim$pg\-Input\-Event\-Manager} ()
\item 
void \hyperlink{classpg_input_event_manager_add5f4d0acf0970c5963dcd5c7e7275b5}{Shut\-Down} ()
\begin{DoxyCompactList}\small\item\em Shuts down the event manager, frees leftover events and listeners, deallocates memory. \end{DoxyCompactList}\item 
void \hyperlink{classpg_input_event_manager_a451a5000cde52f87fdfd7c81fbfb9540}{Update} (float frame\-Time)
\begin{DoxyCompactList}\small\item\em Not used. \end{DoxyCompactList}\item 
void \hyperlink{classpg_input_event_manager_a9fc9092074b92baba1566c3e51ddbaad}{Register\-Listener} (\hyperlink{class_i_event_listener}{I\-Event\-Listener} $\ast$listener, \hyperlink{_i_event_manager_8h_ab13f1eb4f7990ad6a97263126b1e8565}{E\-V\-E\-N\-T\-\_\-\-C\-L\-A\-S\-S} event\-Class=\hyperlink{_i_event_manager_8h_ab13f1eb4f7990ad6a97263126b1e8565a230d22d3c096db888df52a0e5d5ba7ac}{E\-C\-\_\-\-U\-N\-K\-N\-O\-W\-N}, \hyperlink{_i_event_manager_8h_acebeb2e728025f3444b405355a3f8e92}{E\-V\-E\-N\-T\-\_\-\-N\-A\-M\-E} event\-Name=\hyperlink{_i_event_manager_8h_acebeb2e728025f3444b405355a3f8e92a0bdce79d948b8215713bcf669df0b8f1}{E\-\_\-\-U\-N\-K\-N\-O\-W\-N})
\begin{DoxyCompactList}\small\item\em Register a listener to receive input events D\-E\-P\-R\-E\-C\-H\-E\-A\-T\-E\-D. \end{DoxyCompactList}\item 
void \hyperlink{classpg_input_event_manager_ae404352163a7bda1b7392a95600f7eda}{Unregister\-Listener} (\hyperlink{class_i_event_listener}{I\-Event\-Listener} $\ast$listener)
\begin{DoxyCompactList}\small\item\em Unregister a listener. \end{DoxyCompactList}\item 
void \hyperlink{classpg_input_event_manager_a4e5414722dc173201669de70df67352f}{Register\-Event} (int event\-Name, int event\-Class, \hyperlink{struct_i_event_data}{I\-Event\-Data} $\ast$p\-Data)
\begin{DoxyCompactList}\small\item\em Register a keyboard input event. \end{DoxyCompactList}\item 
bool \hyperlink{classpg_input_event_manager_a5682ce21dfb54bd66782605241636d80}{Is\-Key\-Pressed} (unsigned int id)
\begin{DoxyCompactList}\small\item\em Check whether the specified key is pressed. \end{DoxyCompactList}\item 
void \hyperlink{classpg_input_event_manager_aeecb9a05547e503ae0881a450e36d27a}{Map\-Key} (B\-Y\-T\-E virtual\-Key, unsigned int pg\-Key)
\begin{DoxyCompactList}\small\item\em Map a windows key to a palegem key. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Private Member Functions}
\begin{DoxyCompactItemize}
\item 
void \hyperlink{classpg_input_event_manager_a61acee7c96dc6043505b031e38e92737}{Key\-Pressed} (unsigned int id)
\begin{DoxyCompactList}\small\item\em Sets a key's state to pressed. \end{DoxyCompactList}\item 
void \hyperlink{classpg_input_event_manager_a48dca7c25cbe1f2d739f172b189d6fcf}{Key\-Released} (unsigned int id)
\begin{DoxyCompactList}\small\item\em Sets a key's state to released. \end{DoxyCompactList}\item 
void \hyperlink{classpg_input_event_manager_a147e21dbfc604b1630863d119bf75db4}{Dispatch\-Events} (unsigned int pg\-Key, int activation\-Mode)
\begin{DoxyCompactList}\small\item\em Send events to listeners. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Private Attributes}
\begin{DoxyCompactItemize}
\item 
unsigned int \hyperlink{classpg_input_event_manager_ad6cc5b9a13daa533e33ba8fa5d89ff53}{m\-\_\-n\-Button\-States}
\begin{DoxyCompactList}\small\item\em 1 is pressed 0 means released \end{DoxyCompactList}\item 
std\-::map$<$ B\-Y\-T\-E, unsigned int $>$ \hyperlink{classpg_input_event_manager_a9e6f76dc7af85ec3022fd67b268099ea}{m\-\_\-key\-Maps}
\begin{DoxyCompactList}\small\item\em Connects virtual keys to internal keynumbers. \end{DoxyCompactList}\item 
std\-::list$<$ \hyperlink{class_i_event_listener}{I\-Event\-Listener} $\ast$ $>$ \hyperlink{classpg_input_event_manager_a4790e2b9a70dee590435f60923e6db2c}{m\-\_\-listeners}
\begin{DoxyCompactList}\small\item\em List of objects that listen for input events. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Pale\-Gem's keyboard event manager. 

Processed keyboard inputs.

\subsubsection*{Inititalizing}

First you have to map a windows key to a palegem key. This is done by calling \hyperlink{classpg_input_event_manager_aeecb9a05547e503ae0881a450e36d27a}{Map\-Key()}. The virtual key is a windows key (See also E\-Windows\-Virtual\-Keys) while pg\-Key is one of the 32 palegem keys. Note that you can map multiple windows keys to the same palegem key but not vice versa. After mapping the desired keys you will have to take care of sending the W\-M\-\_\-\-K\-E\-Y\-D\-O\-W\-N and W\-M\-\_\-\-K\-E\-Y\-U\-P events from your window procedure to the input event manager, by calling \hyperlink{classpg_input_event_manager_a4e5414722dc173201669de70df67352f}{Register\-Event()} on both messages. Use w\-Param for the event name, e\-K\-P\-E\-C\-\_\-press or e\-K\-P\-E\-C\-\_\-release for the eventclass during the respective message, and N\-U\-L\-L for event data (note that event data is not processed at all, meaning you {\itshape can} send some sort of data to the event manager but it will simply ignore it and do nothing with it, including not sending it to listeners). A good idea is to create your own enum mapping for the palegem keys, e.\-g.

enum My\-Game\-Key\-Maps \{ forward = P\-G\-\_\-\-K\-E\-Y1, backward = P\-G\-\_\-\-K\-E\-Y3, \};

This way you will not have to memorize which P\-G\-\_\-\-K\-E\-Y triggers which action in your game.

\subsubsection*{Getting input from the keyboard}

After yo have mapped some keys you can check for them with \hyperlink{classpg_input_event_manager_a5682ce21dfb54bd66782605241636d80}{Is\-Key\-Pressed()}. This method take a P\-G\-\_\-\-K\-E\-Y argument and checks it against the internal button state with a bitwise A\-N\-D. Note that this will return true as soon and as long as a button is pressed, which makes it unsuitable for text input. N\-O\-T\-E\-: Using \hyperlink{classpg_input_event_manager_a9fc9092074b92baba1566c3e51ddbaad}{Register\-Listener()} is currently deprecheated because events are sent right when they appear, meaning you can only check for one key per frame. For example\-: Using \hyperlink{classpg_input_event_manager_a9fc9092074b92baba1566c3e51ddbaad}{Register\-Listener()} you cannot check if P\-G\-\_\-\-K\-E\-Y1 and P\-G\-\_\-\-K\-E\-Y2 are pressed simultaniously, as you receive either P\-G\-\_\-\-K\-E\-Y1 {\itshape or} P\-G\-\_\-\-K\-E\-Y2 but not both. To achieve such a behaviour, use \hyperlink{classpg_input_event_manager_a5682ce21dfb54bd66782605241636d80}{Is\-Key\-Pressed()}. 

\subsection{Constructor \& Destructor Documentation}
\hypertarget{classpg_input_event_manager_a751b6861a24c5adc0bbf5a57a979a2fe}{\index{pg\-Input\-Event\-Manager@{pg\-Input\-Event\-Manager}!pg\-Input\-Event\-Manager@{pg\-Input\-Event\-Manager}}
\index{pg\-Input\-Event\-Manager@{pg\-Input\-Event\-Manager}!pgInputEventManager@{pg\-Input\-Event\-Manager}}
\subsubsection[{pg\-Input\-Event\-Manager}]{\setlength{\rightskip}{0pt plus 5cm}pg\-Input\-Event\-Manager\-::pg\-Input\-Event\-Manager (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}\label{classpg_input_event_manager_a751b6861a24c5adc0bbf5a57a979a2fe}
\hypertarget{classpg_input_event_manager_a1d1b1aaba16afa0c0c9d311f9b258c4e}{\index{pg\-Input\-Event\-Manager@{pg\-Input\-Event\-Manager}!$\sim$pg\-Input\-Event\-Manager@{$\sim$pg\-Input\-Event\-Manager}}
\index{$\sim$pg\-Input\-Event\-Manager@{$\sim$pg\-Input\-Event\-Manager}!pgInputEventManager@{pg\-Input\-Event\-Manager}}
\subsubsection[{$\sim$pg\-Input\-Event\-Manager}]{\setlength{\rightskip}{0pt plus 5cm}pg\-Input\-Event\-Manager\-::$\sim$pg\-Input\-Event\-Manager (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}\label{classpg_input_event_manager_a1d1b1aaba16afa0c0c9d311f9b258c4e}


\subsection{Member Function Documentation}
\hypertarget{classpg_input_event_manager_a147e21dbfc604b1630863d119bf75db4}{\index{pg\-Input\-Event\-Manager@{pg\-Input\-Event\-Manager}!Dispatch\-Events@{Dispatch\-Events}}
\index{Dispatch\-Events@{Dispatch\-Events}!pgInputEventManager@{pg\-Input\-Event\-Manager}}
\subsubsection[{Dispatch\-Events}]{\setlength{\rightskip}{0pt plus 5cm}void pg\-Input\-Event\-Manager\-::\-Dispatch\-Events (
\begin{DoxyParamCaption}
\item[{unsigned int}]{pg\-Key, }
\item[{int}]{activation\-Mode}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [private]}}}\label{classpg_input_event_manager_a147e21dbfc604b1630863d119bf75db4}


Send events to listeners. 

\hypertarget{classpg_input_event_manager_a5682ce21dfb54bd66782605241636d80}{\index{pg\-Input\-Event\-Manager@{pg\-Input\-Event\-Manager}!Is\-Key\-Pressed@{Is\-Key\-Pressed}}
\index{Is\-Key\-Pressed@{Is\-Key\-Pressed}!pgInputEventManager@{pg\-Input\-Event\-Manager}}
\subsubsection[{Is\-Key\-Pressed}]{\setlength{\rightskip}{0pt plus 5cm}bool pg\-Input\-Event\-Manager\-::\-Is\-Key\-Pressed (
\begin{DoxyParamCaption}
\item[{unsigned int}]{id}
\end{DoxyParamCaption}
)}}\label{classpg_input_event_manager_a5682ce21dfb54bd66782605241636d80}


Check whether the specified key is pressed. 


\begin{DoxyParams}{Parameters}
{\em id} & See E\-Key\-Press\-Key\-Event\-Name. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true if key is pressed. 
\end{DoxyReturn}
\hypertarget{classpg_input_event_manager_a61acee7c96dc6043505b031e38e92737}{\index{pg\-Input\-Event\-Manager@{pg\-Input\-Event\-Manager}!Key\-Pressed@{Key\-Pressed}}
\index{Key\-Pressed@{Key\-Pressed}!pgInputEventManager@{pg\-Input\-Event\-Manager}}
\subsubsection[{Key\-Pressed}]{\setlength{\rightskip}{0pt plus 5cm}void pg\-Input\-Event\-Manager\-::\-Key\-Pressed (
\begin{DoxyParamCaption}
\item[{unsigned int}]{id}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [private]}}}\label{classpg_input_event_manager_a61acee7c96dc6043505b031e38e92737}


Sets a key's state to pressed. 

\hypertarget{classpg_input_event_manager_a48dca7c25cbe1f2d739f172b189d6fcf}{\index{pg\-Input\-Event\-Manager@{pg\-Input\-Event\-Manager}!Key\-Released@{Key\-Released}}
\index{Key\-Released@{Key\-Released}!pgInputEventManager@{pg\-Input\-Event\-Manager}}
\subsubsection[{Key\-Released}]{\setlength{\rightskip}{0pt plus 5cm}void pg\-Input\-Event\-Manager\-::\-Key\-Released (
\begin{DoxyParamCaption}
\item[{unsigned int}]{id}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [private]}}}\label{classpg_input_event_manager_a48dca7c25cbe1f2d739f172b189d6fcf}


Sets a key's state to released. 

\hypertarget{classpg_input_event_manager_aeecb9a05547e503ae0881a450e36d27a}{\index{pg\-Input\-Event\-Manager@{pg\-Input\-Event\-Manager}!Map\-Key@{Map\-Key}}
\index{Map\-Key@{Map\-Key}!pgInputEventManager@{pg\-Input\-Event\-Manager}}
\subsubsection[{Map\-Key}]{\setlength{\rightskip}{0pt plus 5cm}void pg\-Input\-Event\-Manager\-::\-Map\-Key (
\begin{DoxyParamCaption}
\item[{B\-Y\-T\-E}]{virtual\-Key, }
\item[{unsigned int}]{pg\-Key}
\end{DoxyParamCaption}
)}}\label{classpg_input_event_manager_aeecb9a05547e503ae0881a450e36d27a}


Map a windows key to a palegem key. 


\begin{DoxyParams}{Parameters}
{\em virtual\-Key} & Windows key code of the key to be mapped. \\
\hline
{\em pg\-Key} & The P\-G\-\_\-\-K\-E\-Y the specified windows key shall be mapped to. \\
\hline
\end{DoxyParams}
\hypertarget{classpg_input_event_manager_a4e5414722dc173201669de70df67352f}{\index{pg\-Input\-Event\-Manager@{pg\-Input\-Event\-Manager}!Register\-Event@{Register\-Event}}
\index{Register\-Event@{Register\-Event}!pgInputEventManager@{pg\-Input\-Event\-Manager}}
\subsubsection[{Register\-Event}]{\setlength{\rightskip}{0pt plus 5cm}void pg\-Input\-Event\-Manager\-::\-Register\-Event (
\begin{DoxyParamCaption}
\item[{int}]{event\-Name, }
\item[{int}]{event\-Class, }
\item[{{\bf I\-Event\-Data} $\ast$}]{p\-Data}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [virtual]}}}\label{classpg_input_event_manager_a4e5414722dc173201669de70df67352f}


Register a keyboard input event. 


\begin{DoxyParams}{Parameters}
{\em event\-Name} & Usually the w\-Param of the window procedure, but more precisely the windows virtual key number \\
\hline
{\em event\-Class} & Pressed or released? See E\-Key\-Press\-Event\-Class. \\
\hline
{\em p\-Data} & Not used. Use N\-U\-L\-L. \\
\hline
\end{DoxyParams}


Implements \hyperlink{class_i_event_manager_a392a23f11ab77aa893cbef5bd4cd6fa8}{I\-Event\-Manager}.

\hypertarget{classpg_input_event_manager_a9fc9092074b92baba1566c3e51ddbaad}{\index{pg\-Input\-Event\-Manager@{pg\-Input\-Event\-Manager}!Register\-Listener@{Register\-Listener}}
\index{Register\-Listener@{Register\-Listener}!pgInputEventManager@{pg\-Input\-Event\-Manager}}
\subsubsection[{Register\-Listener}]{\setlength{\rightskip}{0pt plus 5cm}void pg\-Input\-Event\-Manager\-::\-Register\-Listener (
\begin{DoxyParamCaption}
\item[{{\bf I\-Event\-Listener} $\ast$}]{listener, }
\item[{{\bf E\-V\-E\-N\-T\-\_\-\-C\-L\-A\-S\-S}}]{event\-Class = {\ttfamily {\bf E\-C\-\_\-\-U\-N\-K\-N\-O\-W\-N}}, }
\item[{{\bf E\-V\-E\-N\-T\-\_\-\-N\-A\-M\-E}}]{event\-Name = {\ttfamily {\bf E\-\_\-\-U\-N\-K\-N\-O\-W\-N}}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [virtual]}}}\label{classpg_input_event_manager_a9fc9092074b92baba1566c3e51ddbaad}


Register a listener to receive input events D\-E\-P\-R\-E\-C\-H\-E\-A\-T\-E\-D. 



Implements \hyperlink{class_i_event_manager_a4bc99cb0ef622ba2ec2ab0e1f2ca16c9}{I\-Event\-Manager}.

\hypertarget{classpg_input_event_manager_add5f4d0acf0970c5963dcd5c7e7275b5}{\index{pg\-Input\-Event\-Manager@{pg\-Input\-Event\-Manager}!Shut\-Down@{Shut\-Down}}
\index{Shut\-Down@{Shut\-Down}!pgInputEventManager@{pg\-Input\-Event\-Manager}}
\subsubsection[{Shut\-Down}]{\setlength{\rightskip}{0pt plus 5cm}void pg\-Input\-Event\-Manager\-::\-Shut\-Down (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [virtual]}}}\label{classpg_input_event_manager_add5f4d0acf0970c5963dcd5c7e7275b5}


Shuts down the event manager, frees leftover events and listeners, deallocates memory. 



Implements \hyperlink{class_i_event_manager_aa5e47321003d80135281a90034c7064e}{I\-Event\-Manager}.

\hypertarget{classpg_input_event_manager_ae404352163a7bda1b7392a95600f7eda}{\index{pg\-Input\-Event\-Manager@{pg\-Input\-Event\-Manager}!Unregister\-Listener@{Unregister\-Listener}}
\index{Unregister\-Listener@{Unregister\-Listener}!pgInputEventManager@{pg\-Input\-Event\-Manager}}
\subsubsection[{Unregister\-Listener}]{\setlength{\rightskip}{0pt plus 5cm}void pg\-Input\-Event\-Manager\-::\-Unregister\-Listener (
\begin{DoxyParamCaption}
\item[{{\bf I\-Event\-Listener} $\ast$}]{listener}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [virtual]}}}\label{classpg_input_event_manager_ae404352163a7bda1b7392a95600f7eda}


Unregister a listener. 



Implements \hyperlink{class_i_event_manager_a5e6327650d496ce27637550bc46d808b}{I\-Event\-Manager}.

\hypertarget{classpg_input_event_manager_a451a5000cde52f87fdfd7c81fbfb9540}{\index{pg\-Input\-Event\-Manager@{pg\-Input\-Event\-Manager}!Update@{Update}}
\index{Update@{Update}!pgInputEventManager@{pg\-Input\-Event\-Manager}}
\subsubsection[{Update}]{\setlength{\rightskip}{0pt plus 5cm}void pg\-Input\-Event\-Manager\-::\-Update (
\begin{DoxyParamCaption}
\item[{float}]{frame\-Time}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [virtual]}}}\label{classpg_input_event_manager_a451a5000cde52f87fdfd7c81fbfb9540}


Not used. 



Implements \hyperlink{class_i_event_manager_a71e4cf7f0b61929a3f878e0d09778d9b}{I\-Event\-Manager}.



\subsection{Member Data Documentation}
\hypertarget{classpg_input_event_manager_a9e6f76dc7af85ec3022fd67b268099ea}{\index{pg\-Input\-Event\-Manager@{pg\-Input\-Event\-Manager}!m\-\_\-key\-Maps@{m\-\_\-key\-Maps}}
\index{m\-\_\-key\-Maps@{m\-\_\-key\-Maps}!pgInputEventManager@{pg\-Input\-Event\-Manager}}
\subsubsection[{m\-\_\-key\-Maps}]{\setlength{\rightskip}{0pt plus 5cm}std\-::map$<$B\-Y\-T\-E, unsigned int$>$ pg\-Input\-Event\-Manager\-::m\-\_\-key\-Maps\hspace{0.3cm}{\ttfamily [private]}}}\label{classpg_input_event_manager_a9e6f76dc7af85ec3022fd67b268099ea}


Connects virtual keys to internal keynumbers. 

\hypertarget{classpg_input_event_manager_a4790e2b9a70dee590435f60923e6db2c}{\index{pg\-Input\-Event\-Manager@{pg\-Input\-Event\-Manager}!m\-\_\-listeners@{m\-\_\-listeners}}
\index{m\-\_\-listeners@{m\-\_\-listeners}!pgInputEventManager@{pg\-Input\-Event\-Manager}}
\subsubsection[{m\-\_\-listeners}]{\setlength{\rightskip}{0pt plus 5cm}std\-::list$<${\bf I\-Event\-Listener}$\ast$$>$ pg\-Input\-Event\-Manager\-::m\-\_\-listeners\hspace{0.3cm}{\ttfamily [private]}}}\label{classpg_input_event_manager_a4790e2b9a70dee590435f60923e6db2c}


List of objects that listen for input events. 

\hypertarget{classpg_input_event_manager_ad6cc5b9a13daa533e33ba8fa5d89ff53}{\index{pg\-Input\-Event\-Manager@{pg\-Input\-Event\-Manager}!m\-\_\-n\-Button\-States@{m\-\_\-n\-Button\-States}}
\index{m\-\_\-n\-Button\-States@{m\-\_\-n\-Button\-States}!pgInputEventManager@{pg\-Input\-Event\-Manager}}
\subsubsection[{m\-\_\-n\-Button\-States}]{\setlength{\rightskip}{0pt plus 5cm}unsigned int pg\-Input\-Event\-Manager\-::m\-\_\-n\-Button\-States\hspace{0.3cm}{\ttfamily [private]}}}\label{classpg_input_event_manager_ad6cc5b9a13daa533e33ba8fa5d89ff53}


1 is pressed 0 means released 



The documentation for this class was generated from the following files\-:\begin{DoxyCompactItemize}
\item 
Inc/\hyperlink{pg_input_event_manager_8h}{pg\-Input\-Event\-Manager.\-h}\item 
Source/\hyperlink{pg_input_event_manager_8cpp}{pg\-Input\-Event\-Manager.\-cpp}\end{DoxyCompactItemize}
